unit guiU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, PendulumGraph, StdCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Button2: TButton;
    Timer2: TTimer;
    Edit3: TEdit;
    Edit4: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Button3: TButton;
    Button4: TButton;
    PendulumGraph1: TPendulumGraph;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  t : real;
  e1, e2 : Int64;
  res : Int64;
implementation

{$R *.DFM}  {$R Project.RES}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
PendulumGraph1.Paint;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    PendulumGraph1.Initialise;
    Timer1.Enabled := True;
    QueryPerformanceFrequency(res);

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
try
PendulumGraph1.DrawPoint(strToFloat(Edit2.text),strToFloat(Edit1.Text))
except
Application.MessageBox('Please enter numerical values', 'Invalid Input', MB_OK+MB_ICONERROR);
end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
    t := t + pi/100;
    PendulumGraph1.DrawPoint(t, sin(t));


end;

procedure TForm1.Button2Click(Sender: TObject);
begin

t := 0;
Timer2.Enabled := True;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
try
begin
PendulumGraph1.SetScale(strToFloat(edit3.text), strToFloat(edit4.text));
PendulumGraph1.Initialise;
end;
except
Application.MessageBox('Please enter numerical values', 'Invalid Input', MB_OK+MB_ICONERROR);
end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
PendulumGraph1.Initialise;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
PendulumGraph1.AutoScale := true;
PendulumGraph1.SetOrigin(PendulumGraph1.AxisOrigin.x, 2* PendulumGraph1.ClientRect.Bottom div 3);
end;

end.
